关于struts的<logic:iterate>标签问题,希望各位大虾能给个明确的指点.谢谢了!!

来源:百度知道 编辑:UC知道 时间:2024/05/13 05:50:22
最近做了个小程序,需要用<logic:iterate>这个标签打印从数据库取出来的值.我是这么做的,可是不对.不知道是为什么?
先把数据库读出来的值存入ActionForm的每个属性中,然后在把ActionForm的对象存入ArrayList传到页面读取,代码如下:
ArrayList arr=dao.query();
request.setAttrubute("arr",arr);

取值:
<logic:iterate id="element1" name="arr">
<logic:iterate id="element2" name="element1">
<bean:write name="element2" property="id"/> //读取ActionForm中ID值
<bean:write name="element2" property="name"/>//ActionForm的name值
</logic:iterate>
</logic:iterate>
页面总是报500错误,没找到错误原因,我怀疑是类型不匹配,可我也不知道怎么改,希望能给点意见.谢谢!

request.setAttribute("arr",arr); Attribute你写错了.

另外这里建议你这样写
<logic:iterate id="element1" name="arr" >
<logic:present name="element1">
<bean:write name="element1" property="id"/>
<bean:write name="element1" property="name"/>
</logic:present>
</logic:iterate>